#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "featurepp.h"

main(int argc, char *argv[]) {
   
   FILE *fpsource, *fpoutput;

   char t[1000];                    // Buffer

   printf("Parsing comma-seperated file to Lines-Format...\n");   

   printf("Open: %s\n", argv[1]);
   if ((fpsource = fopen64(argv[1], "r"))==NULL) {
      printf("error: can't open Sourcefile %s\n", argv[1]);
      exit(1);
   }

   printf("Open: %s\n", argv[2]);
   if ((fpoutput = fopen64(argv[2], "w"))==NULL) {
      printf("error: can't open Sourcefile %s\n", argv[2]);
      exit(1);
   }

  while(readArg(t, fpsource)!=EOF) {
//      writeArg(eins, fpoutput, ' ');      // set pointweight 1
      writeArg(t, fpoutput, '\n');         // write 1st coordinate
      while(readArg(t, fpsource)==',') {     
         writeArg(t, fpoutput, '\n');      // write following coordinates
      }
      writeArg(t, fpoutput, '\n');        // write last coordinate + return
   }

   printf("done.\n");
   fclose(fpsource);
   fclose(fpoutput);
   
}
